1 <?php
2 include(
"header.php");
3 include(
"sidebar.php");
4 include(
"dbconnection.php");
5 ?>
6 <script type=
"text/javascript">
7 function validate()
8 {

9 if
(document.form1.purid.value=="")
10 {
11     alert(
"Enter the Purchase ID");
12     document.form1.purid.focus();
13     
return false;
14 }

15 if
(document.form1.vehid.value=="")
16 {
17     alert(
"Enter the Vehicle ID");
18     document.form1.vehid.focus();
19     
return false;
20 }

21 if
(document.form1.custid.value=="")
22 {
23     alert(
"Enter the Customer ID");
24     document.form1.custid.focus();
25     
return false;
26 }

27 if
(document.form1.purdate.value=="")
28 {
29     alert(
"Enter Purchase Date");
30     document.form1.purdate.focus();
31     
return false;
32 }

33 if
(document.form1.deldate.value=="")
34 {
35     alert(
"Enter Delivery Date");
36     document.form1.deldate.focus();
37     
return false;
38 }

39 if
(document.form1.comments.value=="")
40 {
41     alert(
"Insert Comments");
42     document.form1.comments.focus();
43     
return false;
44 }

45 if
(document.form1.advance.value=="")
46 {
47     alert(
"Enter the Advance Amount");
48     document.form1.advance.focus();
49     
return false;
50 }

51 if
(document.form1.payment.value=="")
52 {
53     alert(
"Enter the Payment Type");
54     document.form1.payment.focus();
55     
return false;
56 }

57 if
(document.form1.address.value=="")
58 {
59     alert(
"Enter the Address");
60     document.form1.address.focus();
61     
return false;
62 }

63 if
(document.form1.city.value=="")
64 {
65     alert(
"Enter the City");
66     document.form1.city.focus();
67     
return false;
68 }

69 if
(document.form1.zip.value=="")
70 {
71     alert(
"Enter the Zipcode");
72     document.form1.zip.focus();
73     
return false;
74 }
75 }
76 </script>
77 <?php
78 $dt= date(
"Y-m-d");
79
80 if
(isset($_POST["submit"]))
81 {
82
83 $sql =
"insert into buyvehicles(purchaseid,vehicleid,custid ,purchasedate,deliverydate,comments,paid,paymenttype,address,city,zipcode) values('$_POST[purid]','$_POST[vehid]','$_POST[custid]','$_POST[purdate]','$_POST[deldate]','$_POST[comments]','$_POST[advance]','$_POST[payment]','$_POST[address]','$_POST[city]','$_POST[zipcode]')";
84 if
(!mysql_query($sql,$con))
85   {
86   die(
'Error: ' . mysql_error());
87   }
88 $ctins = mysql_affected_rows();
89 }
90 ?>
91         
92                             
93         <div id=
"main">
94             
95             <a name=
"TemplateInfo"></a>
96             <h1>buyveh</h1>
97
98 <?php

99 if
($ctins == 1)
100 {
101     echo
"<center><b>Custmer registered Successfully...</b></center><br>";
102     echo
"<center><b><a href='login.php'>Click here to Login.</a></b></center>";
103 }

104 else

105 {
106
107     ?>
108         <form id=
"form1" name="form1" method="post" action="" onsubmit="return validate()">
109             <table width=
"427" border="0">
110               <tr>
111                 <th width=
"170" height="33" scope="row">Purchase Id</th>
112                 <td width=
"247">
113                   <label
for="purid"></label>
114                   <input type=
"text" name="purid" id="purid" onKeypress="if (event.keyCode < 45 || event.keyCode > 57) event.returnValue = false;" />
115                 </td>
116               </tr>
117               <tr>
118                 <th height=
"37" scope="row">Vehicle Id
119                   <label
for="vehid"></label></th>
120                 <td><input type=
"text" name="vehid" id="vehid" onKeypress="if (event.keyCode < 45 || event.keyCode > 57) event.returnValue = false;"/></td>
121               </tr>
122               <tr>
123                 <th height=
"36" scope="row">Customer Id</th>
124                 <td><label
for="custid"></label>
125                 <input type=
"text" name="custid" id="custid" onKeypress="if (event.keyCode < 45 || event.keyCode > 57) event.returnValue = false;"/></td>
126               </tr>
127               <tr>
128                 <th height=
"34" scope="row">Purchase Date</th>
129                 <td><label
for="purdate"></label>
130                 <input type=
"text" name="purdate" id="purdate" /></td>
131               </tr>
132               <tr>
133                 <th height=
"40" scope="row">Delivery Date</th>
134                 <td><label
for="deldate"></label>
135                 <input type=
"text" name="deldate" id="deldate" /></td>
136               </tr>
137               <tr>
138                 <th height=
"37" scope="row">Comments</th>
139                 <td><label
for="date"></label>
140                 <input type=
"text" name="comments" id="comments" /></td>
141               </tr>
142               <tr>
143                 <th height=
"34" scope="row">Advance</th>
144                 <td><label
for="advance"></label>
145                 <input type=
"text" name="advance" id="advance" onKeypress="if (event.keyCode < 45 || event.keyCode > 57) event.returnValue = false;"/></td>
146               </tr>
147               <tr>
148                 <th height=
"31" scope="row">Payment Type </th>
149                 <td><label
for="payment"></label>
150                 <input type=
"text" name="payment" id="payment" /></td>
151               </tr>
152               <tr>
153                 <th height=
"33" scope="row">Address</th>
154                 <td><input type=
"text" name="address" id="address" /></td>
155               </tr>
156               <tr>
157                 <th height=
"36" scope="row">City</th>
158                 <td><input type=
"text" name="city" id="city" /></td>
159               </tr>
160               <tr>
161                 <th scope=
"row">Zipcode</th>
162                 <td><input type=
"text" name="zipcode" id="zipcode" onKeypress="if (event.keyCode < 45 || event.keyCode > 57) event.returnValue = false;"/></td>
163               </tr>
164           </table>
165             <table width=
"427" border="0">
166               <tr>
167                 <th width=
"181" scope="row">&nbsp;</th>
168                 <td width=
"236"><br />
169                   <input type=
"submit" name="submit" id="submit" value="Register" /></td>
170               </tr>
171           </table>
172         </form>
173         <?php
174 }
175 ?>
176         <p>&nbsp;</p>
177         </div>
178         
179 <?php
180 include(
"footer.php");
181 ?>


Gõ tìm kiếm nhanh...